#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# This program is free software; you can redistribute it and/or modify  
# it under the terms of the GNU General Public License as published by  
# the Free Software Foundation; either version 2 of the License, or     
# (at your option) any later version.                                   
#                                                                         
# A copy of the license can be found in the license.txt file supplied   
# with this software or at: http://www.gnu.org/copyleft/gpl.html       
#

from jutebag import phpserialize

from icolumn import IColumn


class   SuperColumn(IColumn) :
    SIZE_ADDITIONAL = 256

    '''Super Column
    '''
    def __init__(self, name=None) :
        self._name = name

        self._local_delete_time = 0
        self._marked_for_delete_at = 0

        self._columns = {}

        self._size = SIZE_ADDITIONAL
        ## __init__()

    def getName(self) :
        return self._name
    def setName(self, name) :
        self._name = name
    name = property(getName, setName)

    def getMarkedForDeleteAt(self) :
        return  self._marked_for_delete_at

    def getLocalDeletionTime(self) :
        return  self._local_delete_time

    def markForDeleteAt(self, local_delete_time, timestamp) :
        self._local_delete_time = local_delete_time
        self._marked_for_delete_at = timestamp

    def isMarkedForDelete(self) :
        return self._marked_for_delete_at != 0

    def addColumn(self, column) :
        cname = column.name
        self._columns[ cname ] = column

        self._size += column.getColumnSize()
        ## addColumn()

    def getColumnSize(self) :
        return self._size
        ## getColumnSize()

    def getColumnCount(self) :
        return  len(self._columns)
        ## getColumnCount()

    ####-----------------------------------------------------------####

    def __str__(self) :
        result = ['<SuperColumn ',]
        result.append(self.name)
        result.append(':')
        if self.isMarkedForDelete() :
            result.append('D')
        else :
            result.append('A')
        result.append('>')

        return ''.join(result)
        ## __str__()

    ####-----------------------------------------------------------####

    class   Serializer(object) :

        @staticmethod
        def serialize(column) :
            '''serialize column into stream
            '''
            raise NotImplementedError
            ## serialize()

        @staticmethod
        def deserialize(column_serialized) :
            '''deserialize column
            '''
            raise NotImplementedError
            ## deserialize()

        ## class Serializer()

    ## class Column


